﻿using System.Collections.Generic;
using Batman.Cms.Core.Controllers;
using Batman.Cms.Core.Core.Attributes;
using Batman.Cms.Core.Services;
using Batman.Cms.Domains;
using Batman.Cms.Services.Applications;
using Batman.Cms.Services.Applications.Filters;
using Batman.Cms.Services.Applications.Inputs;
using Microsoft.AspNetCore.Mvc;

namespace Batman.Cms.Controllers.Applications
{
    public class ApplicationDataItemController : BatmanController
    {
        public ApplicationDataItemReader reader { get; set; }

        public ApplicationDataItemManager applicationDataItemManager { get; set; }

        [AcceessOriginal]
        public IActionResult Create(CreateApplicationDataItemInput model)
        {
            var result = applicationDataItemManager.Create(model);

            return Json(result);
        }

        [AcceessOriginal]
        public IActionResult Remove(List<int> ids)
        {
            base.Remove<ApplicationDataItem>(ids);
            return Json(new { });
        }

        [AcceessOriginal]
        public IActionResult Get(ApplicationDataItemFilter filter)
        {
            var results = reader.Get(filter);
            return Json(results);
        }
    }
}
